package fr.unice.polytech.chord.core.messages.asynchronous;

import java.util.Map;

import fr.unice.polytech.chord.core.ChordNode;
import fr.unice.polytech.chord.core.Entry;
import fr.unice.polytech.chord.core.Key;
import fr.unice.polytech.chord.core.responses.asynchronous.ActionResponseMessage;
import fr.unice.polytech.chord.core.responses.asynchronous.AsynchronousResponseMessage;

/**
 * Add all the given entries to the {@link ChordNode} which handles this
 * message.
 * 
 * @author Anthony Parisy
 * @author Laurent Pellegrino
 * @author Marc Valdener
 * 
 * @version 10/28/2009
 */
@SuppressWarnings("serial")
public class AddEntriesMessage extends AsynchronousMessage {

	private Map<Key, Entry<String>> entriesToAdd;

	/**
	 * Constructor.
	 * 
	 * @param entries
	 *            the entries to add.
	 */
	public AddEntriesMessage(Map<Key, Entry<String>> entries) {
		this.entriesToAdd = entries;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public AsynchronousResponseMessage handle(ChordNode node) {
		return new ActionResponseMessage(node.addEntries(this.entriesToAdd));
	}
}
